package com.base.cloud.gateway.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.cloud.netflix.zuul.filters.SimpleRouteLocator;
import org.springframework.cloud.netflix.zuul.filters.discovery.DiscoveryClientRouteLocator;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RefreshScope
@RestController
@RequestMapping("/config")
public class ConfigController {

    @Value("${foo}")
    String foo;

    @Autowired
    DiscoveryClientRouteLocator discoveryClientRouteLocator;

    @Autowired
    SimpleRouteLocator simpleRouteLocator;

    @RequestMapping("/routes")
    public void showRoutes() {
        simpleRouteLocator.getRoutes().forEach(System.out::println);
    }

    @RequestMapping("/foo")
    public String foo() {
        return foo;
    }

}
